package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * sky-take-out
 * com.sky.controller.admin
 *
 * @author Ablecisi
 * @version 1.0
 * 2025/3/30
 * 13:45
 */
@RestController("AdminShopController")
@RequestMapping("/admin/shop")
@Slf4j
@Api(tags = "店铺相关模块")
public class ShopController {
    private final ShopService shopService;

    @Autowired
    public ShopController(ShopService shopService) {
        this.shopService = shopService;
    }

    /**
     * 设置店铺状态
     *
     * @param status 店铺状态
     * @return 设置结果
     */
    @PutMapping("/{status}")
    @ApiOperation("设置店铺状态")
    public Result<String> setStatus(@PathVariable Integer status) {
        log.info("设置店铺状态为: {}", status == 1 ? "营业中" : "打烊中");
        shopService.setStatus(status);
        return Result.success("店铺状态修改成功");
    }

    /**
     * 获取店铺状态
     *
     * @return 店铺状态
     */
    @GetMapping("/status")
    @ApiOperation("获取店铺状态")
    public Result<Integer> getStatus() {
        Integer status = shopService.getStatus();
        log.info("获取店铺状态: {}", status == 1 ? "营业中" : "打烊中");
        return Result.success(status);
    }
}
